home *** CD-ROM | disk | FTP | other *** search
- Path: news.voicenet.com!usenet
- From: deaton@cygnus.rsabbs.com
- Newsgroups: comp.lang.c++
- Subject: Structure names are pointers? Writing to them?
- Date: 16 Mar 1996 06:17:28 GMT
- Organization: Voicenet - Internet Access - (215)674-9290
- Message-ID: <4idmdo$2b2@news.voicenet.com>
- NNTP-Posting-Host: d02.rsabbs.com
- X-Newsreader: SPRY News 3.03 (SPRY, Inc.)
-
-
- I'm using several random access data files in my program(Written in TurboC/C++), and all except for one are ARRAYS of STRUCTURES.
- With these files, I have no syntax problems reading and writing to them.
- For instance:
-
- FILE * fptr;
- blahS blah[15];
-
- ...code to populate structure...
-
- fptr=fopen("blah.dat","w+");
- fwrite(blah,sizeof(blah),1,fptr);
- fclose(fptr);
-
- This bit of code works fine, but when I try to write only one structure:
-
- FILE * fptr;
- blahS blah;
-
- ...code to populate structure...
-
- fptr=fopen("blah.dat","w+");
- fwrite(blah,sizeof(blah),1,fptr);
- fclose(fptr);
-
- my compiler spits out an error. As far as I understood, structure names acted the
- same way as array names: they are pointers. So why isn't this working? I really don't
- want to declare a structure array of 1 element. It would work, but that would be pretty lame.
-
- Thankyou :),
-
- The Hermit
- deaton@cygnus.rsabbs.com
-